#include "VECTOR2.H"

Vector2 originVector2(){
	Vector2 retVal;
	retVal.x = 0;
	retVal.y = 0;
	return retVal;
}
Vector2 copyVector2(Vector2 old){
	Vector2 retVal;
	retVal.x = old.x;
	retVal.y = old.y;
	return retVal;
}
Vector2 transformVector2(Vector2 old, Matrix3 transformation){
	Vector2 retVal;
	float len = old.x*transformation.M[2][0]+old.y*transformation.M[2][1]+transformation.M[2][2];
	retVal.x = (old.x*transformation.M[0][0]+old.y*transformation.M[0][1]+transformation.M[0][2])/len;
	retVal.y = (old.x*transformation.M[1][0]+old.y*transformation.M[1][1]+transformation.M[1][2])/len;
	return retVal;
}

float lengthVector2(Vector2 vec)
{
	return sqrt(vec.x * vec.x + vec.y + vec.y);
}

float lengthSquareVector2(Vector2 vec)
{
	return vec.x * vec.x + vec.y + vec.y;
}
